package com.building.hcrm.base;

import java.util.EventListener;

import com.building.hcrm.model.SysUser;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Spinner;

public abstract class BaseStaffSelector extends LinearLayout
{

	protected final String LTAG = this.getClass().getSimpleName();

	// 选取控件按钮
	protected Spinner spinner;
	protected Button btnPrevBed;
	protected Button btnNextBed;

	protected SelectedStaffListener _selectedStaffListener;
	protected Context _context;
	protected SysUser _currentStaff; // 当前被选取
	protected int _currentStaffPosition = -1;// 当前选中index;

	public BaseStaffSelector(Context context)
	{
		super(context);
		_context = context;
	}

	public BaseStaffSelector(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		_context = context;
	}

	/**
	 * 选取事件响应接口
	 */
	public interface SelectedStaffListener extends EventListener
	{
		public void onSelectedStaff(SysUser inStaff);
	}

	public void setOnSelectedStaffListener(SelectedStaffListener listener)
	{
		_selectedStaffListener = listener;
	}

	protected void setOnSelectedStaff(SysUser inStaff)
	{
		if (_selectedStaffListener != null)
		{
			_selectedStaffListener.onSelectedStaff(inStaff);
		}
	}

	/**
	 * 获取当前被选取对象
	 * 
	 * @return
	 */
	public SysUser getCurrentStaff()
	{
		return _currentStaff;
	}

	public abstract Boolean setStaff(int position) throws Exception;

	public abstract Boolean setStaff(SysUser inStaff) throws Exception;

	public abstract void load(int showType);

	public abstract void load(int showType, SysUser defaultInStaff);

}
